/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.swirrel.listener;

import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;

import org.swirrel.util.MethodCall;
import org.swirrel.util.SwirrelException;

/**
 *
 * @author Gronau
 */
public class SwirrelMouseMotionListener extends AbstractSwirrelListener implements MouseMotionListener {

    private final MethodCall mouseDraggedCall;
    private final MethodCall mouseMovedCall;

    public SwirrelMouseMotionListener(
            MethodCall mouseDraggedCall,
            MethodCall mouseMovedCall) {
        this.mouseDraggedCall = mouseDraggedCall;
        this.mouseMovedCall = mouseMovedCall;
        if (!checkSignature(mouseDraggedCall, MouseEvent.class) ||
            !checkSignature(mouseMovedCall, MouseEvent.class)) {
            throw new SwirrelException("Method must have none or one MouseEvent argument");
        }
    }

    public void mouseDragged(MouseEvent e) {
        call(mouseDraggedCall, e);
    }

    public void mouseMoved(MouseEvent e) {
        call(mouseMovedCall, e);
    }
}
